package tutorial;

import gui.RiskGUI;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import resources.images.ImagesPath;

import com.swtdesigner.SWTResourceManager;

public class StepOne implements TutorialWindow {

	private Label hereYouAreText;
	protected Object result;
	protected Shell shell;
	protected Shell parent;
	private Tutorial tutorial;

	/**
	 * Create the dialog
	 * @param parent
	 * @param tutorial 
	 */
	public StepOne(Shell parent, Tutorial tutorial) {
		this.parent = parent;
		this.tutorial = tutorial;
	}

	/**
	 * Open the dialog
	 */
	public void open() {
		createContents();
		shell.open();
		shell.layout();
	}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents() {
		shell = new Shell(parent, SWT.DIALOG_TRIM);
		shell.addShellListener(new ShellAdapter() {
			public void shellClosed(final ShellEvent e) {
				tutorial.endTutotial();
			}
		});
		shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
		shell.setBackgroundImage(new Image(Display.getDefault(), ImagesPath.getImageStream("tutorial_background.png")));
		shell.setLocation(parent.getBounds().width,0);
		shell.setSize(219, RiskGUI.display.getClientArea().height);
		shell.setText("Step One");

		final Label welcomeToRiskLabel = new Label(shell, SWT.CENTER);
		welcomeToRiskLabel.setBounds(0, 10, 213, 87);
		welcomeToRiskLabel.setForeground(SWTResourceManager.getColor(255, 0, 0));
		welcomeToRiskLabel.setFont(SWTResourceManager.getFont("Comic Sans MS", 22, SWT.NONE));
		welcomeToRiskLabel.setText("Step one: create a game");

		hereYouAreText = new Label(shell, SWT.WRAP);
		hereYouAreText.setBounds(10, 124, 193, 153);
		hereYouAreText.setText("The first thing you'll have to do to start playing is creat a new game. This can be done in two diffrent ways (click on the one you like):");
		hereYouAreText.setFont(SWTResourceManager.getFont("Comic Sans MS", 12, SWT.NONE));

		final Button newGameLabel = new Button(shell, SWT.NONE);
		newGameLabel.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent arg0) {
				NewGame newGame = new NewGame(parent, tutorial);
				shell.setVisible(false);
				newGame.open();
			}
		});
		newGameLabel.setFont(SWTResourceManager.getFont("Comic Sans MS", 16, SWT.NONE));
		newGameLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		newGameLabel.setText("New Game");
		newGameLabel.setBounds(46, 317, 109, 33);

		final Label newGameLabel_1 = new Label(shell, SWT.NONE);
		newGameLabel_1.setBounds(38, 351, 131, 22);
		newGameLabel_1.setFont(SWTResourceManager.getFont("Comic Sans MS", 8, SWT.NONE));
		newGameLabel_1.setText("If you want to start fresh");

		final Button newGameLabel_2 = new Button(shell, SWT.NONE);
		newGameLabel_2.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(final SelectionEvent arg0) {
				LoadGame load = new LoadGame(parent, tutorial);
				shell.setVisible(false);
				load.open();
			}
		});
		newGameLabel_2.setBounds(48, 390, 109, 33);
		newGameLabel_2.setFont(SWTResourceManager.getFont("Comic Sans MS", 16, SWT.NONE));
		newGameLabel_2.setBackground(SWTResourceManager.getColor(255, 255, 255));
		newGameLabel_2.setText("Load Game");

		final Label newGameLabel_1_1 = new Label(shell, SWT.CENTER | SWT.WRAP);
		newGameLabel_1_1.setBounds(38, 425, 131, 33);
		newGameLabel_1_1.setFont(SWTResourceManager.getFont("Comic Sans MS", 8, SWT.NONE));
		newGameLabel_1_1.setText("If you want to continue an old one");
		//
	}

	public Shell getShell() {
		return shell;
	}

}
